I want search for tweets in twitter. It is not working.
$parameters = array('q' => 'oauth');
$result = $connection->get('search', $parameters);
But when I do a user search it working perfectly.
$parameters = array('q' => 'oauth');
$result = $connection->get('users/search', $parameters);
I have also tried the below and that is also not working
$parameters = array('q' => 'oauth');
$result = $connection->get('search/tweets', $parameters);
What could be the reason?
Error message
stdClass Object
(
[errors] => Array
(
[0] => stdClass Object
(
[message] => Sorry, that page does not exist
[code] => 34
)
)
)
You seem to be using the library TwitterOAuth by Abraham Williams.
I know this is an old question but I have just had the same problem as OP and it might keep happening to anyone else since apparently this library has not been updated for a while.
The problem seems to be that Twitter is no longer accepting requests via the version 1 of their API. You have to change the $host variable in the file twitteroauth.php as follows:
/* Set up the API root URL. */
//public $host = "https://api.twitter.com/1/";
public $host = "https://api.twitter.com/1.1/";
Related
I am using API of Xverify for email verifiation
Below is my API code:
require 'XverifyClientAPI.php';
$api_key = 'myapikey'; // Your API Key
$options = array();
$options['type'] = 'json'; // API response type
$options['domain'] = 'addeddomainname';// Reruired your domain name
$client = new XverifyClientAPI($api_key,$options);
$data = array();
$data['email'] = 'test#xverify.com';
$client->verify('email',$data);
echo '<pre>';
echo "valid: ", var_dump($client->is_valid()), "\n";
echo "status: ", $client->status(), "\n";
print_r($client->getReponseAsObject());// Convert the json response into object
Here I have use API key which is provided in my xverify account and domain name which is added in my xverify account
but still its give me error like below
valid: bool(false)
status: bad_request
stdClass Object
(
[syntax] => 1
[handle] => test
[domain] => xverify.com
[catch_all] => unknown
[address] => test#xverify.com
[error] => 0
[status] => bad_request
[responsecode] => 504
[message] => Reach the API Limit
[duration] => 0.013515949249268
)
I am not getting what is the problem with this ,can any body help me ?
Make sure you are using the correct url to call the api, in my case i had to the the domian name us.xverify.com to make it work, before i was using only xverify.com which always gave me the result same as yours(api limit reached), to check the correct api call log in to your xverify account and then click on setting and select email and scroll to the bottom of the page and check the correct url. If the id was created in the us i guess you have to use us.xverify.com
My problem is quite strange (at least to me) as I have a request URL that works in the console but throws the Sorry, that page does not exist error in my php script, even though the connection is up and running.
So this
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['oauth_token'], $_SESSION['oauth_secret']);
$user = $connection->get('account/verify_credentials');
print_r($user);
works great, the $user data is printed out on the screen.
However, I am unable to check a friendship status as:
$x = $connection->get('https://api.twitter.com/1.1/friendships/show.json?source_id=707482092&target_id=755811768&target_screen_name=assetspersonifi');
As I get the error.
When I put this request into the Twitter API console, it gives back the json that I don't receive in my php code.
I'm using Abraham's twitteroauth library but this does not work either:
$follows_faelazo = $connection->get('friendships/exists', array('user_a' => 'blfarago', 'user_b' => 'faelazo'));
if(!$follows_faelazo){
echo 'You are NOT following #faelazo!';
$connection->post('friendships/create', array('screen_name' => 'faelazo'));
} else {
print_r($follows_faelazo);
}
stdClass Object ( [errors] => Array ( [0] => stdClass Object ( [message] => Sorry, that page does not exist [code] => 34 ) ) )
I read that friendships/exists API is no longer supported by the Twitter API and I should use friendships/show but how if it's not working as you see above?
To prove that everything else is working, I can follow others with
$connection->post('friendships/create', array('screen_name' => 'faelazo'));
Why?
I found a way. Here's the documentation
$following = $connection->get('friendships/show', array(
'source_screen_name' => $_SESSION['username'],
'target_screen_name' => $screen_name_to_follow,
));
An alternative would be
$following = $connection->get('friendships/lookup', array('screen_name' => $screen_name_to_follow));
Look it up in Twitter doc.
Currently having a few issues accessing the country from a given user on facebook. I have requested the user_location permission and my graph API call also requests location however I am only ever returned the city and an ID for the location - never an actual country.
My requests etc are below. I am using the standard PHP SDK docs
// graph api request for user data
$request = new FacebookRequest( $session, 'GET', '/me?fields=birthday,name,statuses,photos,location' );
$response = $request->execute();
// get response
$response = $response->getGraphObject();
$data_we_need = array();
$data_we_need['name'] = $response->getProperty('name');
$data_we_need['birthday'] = $response->getProperty('birthday');
$data_we_need['location'] = $response->getProperty('location');
$statuses = $response->getProperty('statuses');
$data_we_need['statuses'] = $statuses->asArray();
$photos = $response->getProperty('photos');
$data_we_need['photos'] = $photos->asArray();
I am returned an results like:
[name] => xxxxxx
[birthday] => 05/14/1990
[location] => __PHP_Incomplete_Class Object
(
[__PHP_Incomplete_Class_Name] => Facebook\GraphObject
[backingData:protected] => Array
(
[id] => 112087812151796
[name] => Gloucester, Gloucestershire
)
)
I need to be able to get country from the location data provided.
Any help would be massively appreciated.
As far as I know the location & hometown fields are user inputs (community pages), hence you won't get stable results using the facebook API. You might rather want to try detecting the country yourself with the IP.
Good evening all,
I am using the PHP code from https://github.com/abraham/twitteroauth
The login works perfectly but when trying to post a status to Twitter i get the following error:
stdClass Object ( [errors] => Array ( [0] => stdClass Object ( [code] => 220 [message] => Your credentials do not allow access to this resource. ) ) )
I am using the following code:
session_start();
require_once('twitteroauth/twitteroauth.php');
require_once('config.php');
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $_SESSION['oauth_token'],
$_SESSION['oauth_token_secret']);
$token_credentials = $connection->getAccessToken($_REQUEST['oauth_verifier']);
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $token_credentials['oauth_token'],
$token_credentials['oauth_token_secret']);
$account = $connection->get('account/verify_credentials');
$status = $connection->post('statuses/update', array('status' => 'Text of status here'));
I have followed the same instructions as the website. Where am i going wrong?
In your case do you have to create an api on twitter ?
https://apps.twitter.com/
If you did, check the configuration of your api.
this link could be helpful.
https://dev.twitter.com/docs/auth/oauth/faq
Let me set the scene:
I'm a PHP developer that needs to take info from a web form and send it into a clients Salesforce. At first I though it was as simple as using Web2Lead. However the client has a Salesforce developer in house.
The in house developer has sent me partner.wsdl and CatalystWebservice.wsdl files along with login details to their sandbox to run all this on. The in house developer has basically said I need to use the SOAP API of Salesforce and once connected and logged in I need to call ->makeContact("FormField1", "FormField2", "etc...");
So after spending all day trying many things and hitting many problems I have finally hit a wall I cannot climb. Here is my PHP code I have now:
<pre>
<?php
define("SOAP_CLIENT_BASEDIR", "../soapclient");
$USERNAME = '******#********' ;
$PASSWORD = '******************************' ;
require_once (SOAP_CLIENT_BASEDIR.'/SforcePartnerClient.php');
require_once (SOAP_CLIENT_BASEDIR.'/SforceHeaderOptions.php');
try {
$mySforceConnection = new SforcePartnerClient();
$mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR.'/partner2.wsdl.xml');
$loginResult = $mySforceConnection->login($USERNAME, $PASSWORD);
$location = $mySforceConnection->getLocation();
$session_ID = $mySforceConnection->getSessionId();
$client = new SoapClient(SOAP_CLIENT_BASEDIR.'/CatalystWebservice.wsdl.xml');
$sforce_header = new SoapHeader("http://soap.sforce.com/schemas/class/CatalystWebservice", "SessionHeader", array( "sessionId" => $session_ID ) );
$client->__setSoapHeaders( array( $sforce_header ) );
$client->makeContact("*****", "*****", "Address1", "Address2", "London", "****", "no-one#****", "0123456789", "07891236456", "New Build Homebuy", "This is my question\n\nAnd an other line", "1", "Test");
} catch (Exception $e) {
print_r($e);
}
?>
</pre>
I have starred out sensitive information for here. When I run the above code I get the following output:
SoapFault Object
(
[message:protected] => UNKNOWN_EXCEPTION: An unexpected error occurred. Please include this ErrorId if you contact support: ***********-*** (***********)
[string:Exception:private] =>
[code:protected] => 0
[file:protected] => /home/******/public_html/********/test/partner.php
[line:protected] => 23
[trace:Exception:private] => Array
(
[0] => Array
.....
And the CatalystWebservice.wsdl.xml file
The in house developer has developed something in C# to test his WebService and it works perfectly fine so it must be something I am not doing right. What am I doing incorrectly?
I found the solution... I had to make sure I was sending the data as an associative array like so:
$response = $client->makeContact
(
array
(
"sLastName" => (string) $wpcf7_data->posted_data['last-name'],
"sFirstName" => (string) $wpcf7_data->posted_data['first-name'],
"sAddress1" => (string) $wpcf7_data->posted_data['address-one'],
"sAddress2" => (string) $wpcf7_data->posted_data['address-two'],
"sCity" => (string) $wpcf7_data->posted_data['town-city'],
"sPostcode" => (string) $wpcf7_data->posted_data['post-code'],
"sEmail" => (string) $wpcf7_data->posted_data['email-address'],
"sPhone" => (string) $wpcf7_data->posted_data['telephone'],
"sMobile" => (string) "",
"sEnquiries" => (string) $wpcf7_data->posted_data['enquiry'],
"sComment" => (string) $wpcf7_data->posted_data['comments'],
"sPropertyID" => (string) wpcf7_special_mail_tag_for_post_data( "", "_post_id" ),
"sPropertyName" => (string) wpcf7_special_mail_tag_for_post_data( "", "_post_title" ),
)
);