Jump to content

JTapp

Members
  • Posts

    251
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

JTapp's Achievements

Member

Member (2/5)

0

Reputation

  1. The following code worked. After researching and discovering there are curl issues with the php.ini file - and choosing not to edit the .ini, I found this absolute alternative It ain't pretty but I didn't expect it to be. <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://www.apiwebsite.com"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $result = curl_exec($ch); curl_close($ch); $result = preg_replace("#(<\s*a\s+[^>]*href\s*=\s*[\"'])(?!http)([^\"'>]+)([\"'>]+)#",'$1http://www.apiwebsite.com/$2$3', $result); echo $result ?>
  2. Ok.. in the off chance the recommendation was a typo, I changed http_json_post to http_post_data That didn't do anything. I can't seem to find consistency on the internet regarding how to write what is in the API Documentation: GET api/NAMEOFAPI?PrimaryNameID={DesiredPrimaryNameID} The error message that I'm getting is Internal Server Error I'm sure it has to do with how I'm posting the parameters. Its also clear that I don't understand the difference between $url and $webservice_url. All help is appreciated.. <?php $url='http://xx.xxx.org/xxx/xxx/xxxWebApi.mode'; //Am I supposed to put a concatenated ? after .mode ? $data = array(NameOfField => 'IDnumber'); function http_json_post($url, $data) { $ch = curl_init($url); curl_setopt_array($ch, array( CURLOPT_RETURNTRANSFER => 1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => $data_string = json_encode($data), CURLOPT_HTTPHEADER => array( 'Content-Type: application/json', // tell the server we are sending it JSON 'Content-Length: ' . strlen($data_string)) // tell it how long it is ) ); $output = curl_exec($ch); curl_close($ch); return $output; } $webservice_url = 'http://xx.xxx.org/xxx/xxx/xxxWebApi.mode/api/NAMEofAPI?NameOfField=Value'; // actual API URL $result = http_json_post($webservice_url, array('NameofField' => 'value')); ?>
  3. Based on this feedback I sat through a json course on lynda.com looking for anything that spoke to http_json_post() Now I understand that is not a standard item. I've also read ALOT about json_decode and have explored the world of $params Figuring I needed to utilize the API documentation, I tried to insert $params = array('field name' => 'desired result'); I believe I've gone full circle. Don't be hatin' though Three days of non-stop attempted self-education has demonstrate that I'm trying, right?
  4. The API developer - "The API will pass back XML formatted or JSON formatted and it is in compliance with Web API 2. GET api?/productname?requiredfieldID={desiredfieldID} The requiredfieldID has to be defined in the request URI" This is where I'm getting hung up on the json_decode and how the array is configured.
  5. ignace - I found an extra closed parenthesis and got rid of it, then the last line caused a hang up and ultimately it produced an internal server error upon removing it I got zero errors, but I also got zero data I tried changing $result to the $echo line as shown below - which is the code I'm using - but now all I'm getting is the single word "Array" Thank you <?php $url = 'myapiurl'; $data = array('a_field_title' => 'desired_result', 'a_field_title2' => 'desired_result2'); function http_json_post($url, $data) { $curl = curl_init($url); curl_setopt_array($ch, array( CURLOPT_RETURNTRANSFER => 1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => $data_string = json_encode($data), // your data in JSON CURLOPT_HTTPHEADER => array( 'Content-Type: application/json', // tell the server we are sending it JSON 'Content-Length: ' . strlen($data_string)) // tell it how long it is ) ); $output = curl_exec($curl); curl_close($curl); return $output; } $webservice_url = 'actualAPI_URL'; // actual API URL echo $data; ?>
  6. Hi - I nominate the following advanced member for simply giving me some direction so I can further my skills. http://forums.phpfreaks.com/user/115259-boompa/
  7. For clarity's sake- I am trying to learn how to open a file on an IP address within my PHP. If I need to go take a course in cURL (because that's the advice you guys would give) Then I have my answer.
  8. Again. I'm scouring the internet trying to teach myself. The only help I'm asking for is direction to a resource. Somebody out there might be able to direct me to a resource so I can learn how to do this?
  9. So basically what you guys are all seemingly upset about is not having access to the actual API. Which is my client's product. The site rules don't state I have to provide actual code to get assistance. In fact, just the opposite.. the rules state content will never be deleted and cautions about posting information for all to see. Sounds like I'm in a catch 22. I'm pretty close to figuring it out based on the information I received before all of the hijacks. I'll keep trying to be self-sufficient for other 'students' to potentially benefit from. Hopefully, my immature and painful path to get to where I need to be, will end in a solution that someone else can use. Based on what I'm seeing, odds are that path will likely result in me finding some sort of less organized, and much younger php forum and I can cut and paste the resolution here. Then again, maybe somebody who is well rested will read this.. with a desire to help teach.. instead of a desire to do it themselves and mark the post as solved..
  10. oops - the code contains proprietary data
  11. OK I ditched the last post and I think I'm onto something with $file = fopen I'm now in search of how to add parameters to it
  12. Currently playing with this - For ignace - the source is: https://garethpoole.com/sending-post-api-php/ I'm pretty sure my last comment about the file type is exactly the problem. $url = 'http://webservice.local/data.json'; $data = array("name" => "Gareth", "email" => "gareth@mail.com"); $response = sendPostData($url, $data); function sendPostData($url, $post){ $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post)); return curl_exec($ch); }
  13. Is there any chance that since the file type I am trying to access is a .MODE file that it is rejecting the connection?
  14. Geez Ignace.. Hijack threads much? Does the fact that I'm NOT a "Guru" or "Advanced Member" mean anything? Para 1.) I would have no idea how to find that or what it is. After I pick myself off the ground from your post, I'll go check it out. Para 2.) You are 100% incorrect and the comment provokes a major topic jump and irrelevant discussion Para 3.) I will try to decipher what you are talking about with this: I found that code on another website and pasted it in to see if that was the right road to travel. I'm nearly 50 years old and owe $30k in student loans. My school days are over. BUT as I mentioned earlier in this thread.. I recently joined lydna.com to try to find an answer prior to my post.. I can't remember if that's where I got that code from as it is not the only place I had been scouring. Para 4.) See opening sentance. Para 5.) I don't lie and have no real need to lie. Para 6.) Apology accepted. I have been working nonstop on trying to get this resolved before a trade show.. I'm hoping there is no need to continue this discussion. So - Unless you guys want to kick me off the site, I would like to go back to my problem and skip further investigation into background speculations. I was actually getting somewhere with jcbones Yours, Less than a newbie.. please don't be hatin
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.